<?php

require_once __DIR__ . '/../inc/Wechat.php';
/***************************/

class Tip extends Wechat{

    private $firstTip = false;
    private $secondTip = false;
    private $thirdTip = false;

    private $firstTime;
    private $secondTime;
    private $thirdTime;

    private $_Mumbo;


    function __construct()
    {
        parent::__construct();
        $this->firstTime = strtotime('2018-10-20 06:50:00');
        $this->secondTime = strtotime('2018-10-20 07:00:00');
        $this->thirdTime = strtotime('2018-10-20 07:10:00');

    }

    function dealCus()
    {
        parent::dealCus();
        if(!$this->firstTip){
            if(time()>$this->firstTime){
\Hanson\Vbot\Message\Text::send($this->_Mumbo,'起床没,帮我买猪腰,收到请回复!');
            }
        }elseif(!$this->secondTip){
            if(time()>$this->secondTime){
                \Hanson\Vbot\Message\Text::send($this->_Mumbo,'快去买猪腰?收到请回复!');
            }
        }elseif(!$this->thirdTip){
            if(time()>$this->thirdTime){
                \Hanson\Vbot\Message\Text::send($this->_Mumbo,'猪腰买了没?');
            }
        }

    }
    function dealMsg($message)
    {
        parent::dealMsg($message);
        if($message['fromType']=='Friend' and $message['from']['UserName']==$this->_Mumbo){
            if(!$this->firstTip){
                if(time()>$this->firstTime){
                    $this->firstTip=true;
                }
            }elseif(!$this->secondTip){
                if(time()>$this->secondTime){
                    $this->secondTip=true;
                }
            }elseif(!$this->thirdTip){
                if(time()>$this->thirdTime){
                    $this->thirdTip=true;
                }
            }
        }
    }

    function initConfig()
    {
        $this->_Mumbo = vbot('friends')->getUsernameByNickname('Mumbo', $blur = false);
        var_dump($this->_Mumbo);
    }


}




$a = new Tip();
$a->vbot->server->serve();